home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
telecomm
/
zmdm.zoo
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-04-27
|
16KB
|
887 lines
/*
* Main Module
*
* Jwahar Bammi
* bang: {any internet host}!dsrgsun.ces.CWRU.edu!bammi
* domain: bammi@dsrgsun.ces.CWRU.edu
* GEnie: J.Bammi
*/
#include "config.h"
#include "zmdm.h"
#include "common.h"
#ifndef Vsync /* Atari forgot these in osbind.h */
#define Vsync() xbios(37)
#endif
#define esc 27
#define cr 0x0d
#define mvto(r,c) EscSeq('Y');Bconout(2,r+040);Bconout(2,c+040)
#ifdef PHONES /* common to this module and phone.c */
char *PhoneFile;
#endif
/* Globals belonging to this module only */
int rs232 = 1, /* Ports */
console = 2;
int speed, /* rs232 setup parameters */
flowctl = 0,
ucr = -1,
rsr = -1,
tsr = -1,
scr = -1;
static int duplex = 0; /* full duplex_p */
#ifdef FLOW_CTRL
/*
* setFlow() - set rs232 flow control
*/
#ifndef REMOTE
void setFlow ()
{
long conin;
int ch, i;
char cc[4] = " 0=";
Bconws("Flow control: ");
EscSeq('p');
for (i=0; i<4; i++) {
Bconws(cc);
Bconws(vflows[i].sflow);
cc[1]++;
}
Bconws("\r\n");
EscSeq('q');
Bconout(2, '\t');
EscSeq('p');
Bconws("What type==>");
EscSeq('q');
conin = Bconin(console); /* get flow type */
if ((conin & 0x00FF0000L) == 0x00610000L)
{
his_screen(); /* hit UNDO */
ResetIoBuf();
finish();
}
ch = (conin & 0x007f) - '0';
Bconout(2, ' ');
if ((ch >= 0) && (ch < i))
flowctl = ch;
Bconws(FLOW_STRING(flowctl));
Bconws("\r\n");
Rsconf(-1, flowctl, -1, -1, -1, -1);
}
#else
void setFlow ()
{
long conin;
int ch, i;
char cc[4] = " 0=";
Bauxws("Flow control: ");
for (i=0; i<4; i++) {
Bauxws(cc);
Bauxws(vflows[i].sflow);
cc[1]++;
}
Bauxws("\r\n");
Bconout(1, '\t');
Bauxws("What type==>");
conin = Bconin(1); /* get flow type */
if (((int)(conin & 0x007f) & CTRL('U')) == CTRL('U'))
{
his_screen(); /* hit UNDO */
ResetIoBuf();
finish();
}
ch = (conin & 0x007f) - '0';
Bconout(1, ' ');
if ((ch >= 0) && (ch < i))
flowctl = ch;
Bauxws(FLOW_STRING(flowctl));
Bauxws("\r\n");
Rsconf(-1, flowctl, -1, -1, -1, -1);
}
#endif /* REMOTE */
#endif /* FLOW_CTRL */
/*
* setBaud() - set rs232 port speed
*/
#ifndef REMOTE
void setBaud ()
{
long conin;
int ch, i;
char cc[4] = " 0=";
Bconws("Baud rate:");
EscSeq('p');
for (i=0; vbauds[i].sbaud != NULL; i++) {
Bconws(cc);
Bconws(vbauds[i].sbaud);
cc[1]++;
}
Bconws("\r\n");
EscSeq('q');
Bconout(2, '\t');
EscSeq('p');
Bconws("What speed==>");
EscSeq('q');
conin = Bconin(console); /* get speed */
if ((conin & 0x00FF0000L) == 0x00610000L)
{
his_screen();
ResetIoBuf();
finish();
}
ch = (conin & 0x007f) - '0';
Bconout(2, ' ');
if ((ch >= 0) && (ch < i))
speed = ch;
else
speed = getbaud();
Bconws(BAUD_STRING(speed));
Baudrate = BAUD_RATE(speed);
Bconws(" Baud\r\n");
/* Set new Baud rate */
/* Txoff(); */
#ifndef HIBAUD
Rsconf(vbauds[speed].ibaud, flowctl, ucr, rsr, tsr, scr);
#else
{
register char *mfp_ptr = (char *) 0xfffffa00L;
conin=Super(0L);
mfp_ptr[0x29] &= 0x7f; /* Clear divide by 16 mode */
mfp_ptr[0x1d] &= 0xf0; /* Stop TImer D */
for (mfp_ptr[0x25] = cbauds[speed].tdd; /* Load Timer D data */
mfp_ptr[0x25] != cbauds[speed].tdd;
mfp_ptr[0x25] = cbauds[speed].tdd);
mfp_ptr[0x1d] |= cbauds[speed].tdc; /* Set Timer D mode */
Super(conin);
}
#endif
Vsync(); Vsync();
/* Txon(); */
}
#else
void setBaud ()
{
char ch;
long conin;
Bauxws("Baud rate: ");
Bauxws("0=19200 1=9600, 2=4800, 3=2400, 4=1200, 5=300\r\n");
Bconout(1, '\t');
Bauxws("What speed==>");
conin = Bconin(1); /* get speed */
if (((int)(conin & 0x007f) & CTRL('U')) == CTRL('U'))
{
his_screen();
ResetIoBuf();
finish();
}
ch = (char) (conin & 0x007f);
Bconout(1, ' ');
switch (ch)
{
case '0': /* 19200 */
speed = 0;
Bauxws("19200");
Baudrate = 19200;
break;
case '1':
speed = 1; /* 9600 */
Bauxws("9600");
Baudrate = 9600;
break;
case '2':
speed = 2; /* 4800 */
Bauxws("4800");
Baudrate = 4800;
break;
case '3':
speed = 4; /* 2400 */
Bauxws("2400");
Baudrate = 2400;
break;
case '4':
speed = 7; /* 1200 */
Bauxws("1200");
Baudrate = 1200;
break;
case '5':
speed = 9; /* 300 */
Bauxws("300");
Baudrate = 300;
break;
default:
speed = getbaud();
Bauxws(BAUD_STRING(speed));
Baudrate = BAUD_RATE(speed);
}
Bauxws(" Baud\r\n");
/* Set new Baud rate */
/* Txoff(); */
Rsconf(speed, flowctl, ucr, rsr, tsr, scr);
Vsync(); Vsync();
/* Txon(); */
}
#endif /* REMOTE */
/*
* help() - display help info and menu
*/
#ifndef REMOTE
void help ()
{
register long conin;
register int x;
extern char *r_filename();
my_screen(); /* Switch to my screen memory */
EscSeq('v'); /* wrap at end of line */
EscSeq('E'); /* clear screen */
mvto(2,11);
EscSeq('p');
Bconws("ZMDM Version: ");
Bconws(ZMDMVERSION);
EscSeq('q');
EscSeq('p');
x =(int) strlen(COMPILER);
x = (80 - x)/2;
mvto(3,x);
Bconws(COMPILER);
EscSeq('q');
mvto(5,21);
Bconws("bammi@cadence.com\r\n\n");
/* Put up menu */
Bconws("\r\n\t");
EscSeq('p'); /* reverse video */
Bconws("Undo");
EscSeq('q'); /* quit reverse video */
Bconws(" to exit.\r\n");
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("Help");
EscSeq('q'); /* quit reverse video */
Bconws(" for this message.\r\n");
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("Escape");
EscSeq('q'); /* quit reverse video */
Bconws(" to send a break.\r\n");
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("T or t");
EscSeq('q'); /* quit reverse video */
Bconws(" to do file transfers and local functions.\r\n");
#ifdef PHONES
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("P or p");
EscSeq('q'); /* quit reverse video */
Bconws(" for Phone services.\r\n");
#endif
if(rez == 2)
{
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("H or h");
EscSeq('q'); /* quit reverse video */
Bconws(" for Hi Rez Toggle (25/50 Lines).\r\n");
}
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("I or i");
EscSeq('q'); /* quit reverse video */
Bconws(" to Invert screen colors.\r\n");
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("D or d");
EscSeq('q'); /* quit reverse video */
Bconws(" to toggle duplex.\r\n");
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("Return");
EscSeq('q'); /* quit reverse video */
Bconws(" to do nothing.\r\n");
#ifdef FLOW_CTRL
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("F or f");
EscSeq('q'); /* quit reverse video */
Bconws(" to set flow control. Currently is ");
EscSeq('p');
Bconws(FLOW_STRING(flowctl));
Bconws(".\r\n");
EscSeq('q');
#endif
Bconws("\t");
EscSeq('p'); /* reverse video */
Bconws("B or b");
EscSeq('q'); /* quit reverse video */
Bconws(" to set baud rate. Currently is ");
EscSeq('p');
Bconws(BAUD_STRING(speed));
Bconws(" Baud.\r\n\r\n");
EscSeq('q');
/* get response */
conin = Bconin(console);
if ((conin & 0x00FF0000L) == 0x00610000L)
{
/* He hit <UNDO> */
his_screen();
ResetIoBuf();
finish();
}
switch((int)(conin & 0x007f))
{
case 'B':
case 'b':
/* Set baud rate */
setBaud();
break;
#ifdef FLOW_CTRL
case 'F':
case 'f':
/* Set flow control */
setFlow();
break;
#endif
case 'T':
case 't':
EscSeq('E'); /* clear screen */
/* Set no flow Control */
#if 0
#ifdef FLOW_CTRL
Rsconf(-1,0,-1,-1,-1,-1);
Vsync(); Vsync();
#endif
#endif
/* Go do transfers */
transfer();
#if 0
#ifdef FLOW_CTRL
/* Flow Control On */
/* Txoff(); */
Rsconf(-1,flowctl,-1,-1,-1,-1);
Vsync(); Vsync();
/* Txon(); */
#endif
#endif
his_screen();
return;
case '\033':
/* Send a break */
sendbrk();
his_screen(); /* Don't wait for the key hit */
return;
case 'd':
case 'D':
duplex ^= 1;
his_screen();
return;
case 'i':
case 'I':
/* Invert screen colors */
his_screen();
if(scolor == 0)
{
EscSeq('b'); /* Foreground color 0 */
Bconout(2, 0);
EscSeq('c'); /* Background color 1 */
Bconout(2, 1);
scolor = 1;
}
else
{
EscSeq('b');